function getElementType(ele) {
  return Object.prototype.toString.call(ele).slice(8, -1)
}
/**
 * 深拷贝
 * @param {*} element
 * @returns
 */
export function deepCopy (element) {
  const type = getElementType(element)
  let result
  if (type === 'Object') {
    result = {}
  } else if (type === 'Array') {
    result = []
  } else {
    result = element
  }

  for (const i in element) {
    const value = element[i]
    const valueType = getElementType(value)
    if (valueType === 'Object' || valueType === 'Array') {
      result[i] = deepCopy(value)
    } else {
      result[i] = value
    }
  }
  return result
}
